from rest_framework import serializers

from goods.models import SpecificationOption, SPUSpecification


class SpecsOptionsSerializer(serializers.ModelSerializer):
    spec = serializers.StringRelatedField(label='规格名称')
    spec_id = serializers.IntegerField(label='规格id')

    class Meta:
        model = SpecificationOption
        fields = ('id', 'value', 'spec', 'spec_id')


class GoodsSpecsSimpleSerializer(serializers.ModelSerializer):
    class Meta:
        model = SPUSpecification
        fields = ('id', 'name')
